#include <stdlib.h>
#include <stdio.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>

int main()
{
	SDL_Surface *screen, *grid;
	SDL_Rect dest;
	
	atexit(SDL_Quit);

	// Iniciar SDL
	if(SDL_Init(SDL_INIT_VIDEO) < 0)
	{
	    printf("No se ha podido iniciar SDL: %s\n", SDL_GetError());
	    exit(1);
	}
	
	// Modo de video
	screen = SDL_SetVideoMode(800, 600, 24, SDL_HWSURFACE);
	if(screen == NULL)
	{
	    printf("No se ha podido establecer el modo de vídeo: %s\n", SDL_GetError());
	    exit(1);
	}	

	grid = IMG_Load("../recursos/img/cubo3d.png");
	if(grid == NULL)
	{
	    printf("No se ha podido cargar la imagen grid: %s\n", SDL_GetError());
	    exit(1);
	}

	dest.x = 25;
	dest.y = 10;
	dest.w = grid -> w;
	dest.h = grid -> h;
	
	// Mando grilla a pantalla
	SDL_BlitSurface(grid, NULL, screen, &dest);

	// Actualizar pantalla
	SDL_Flip(screen);

	sleep(4);
}
